package cn.tedu.seri;

import java.io.Serializable;

/*本类用来封装学生类*/
/*本类如果想要实现序列化，必须实现可序列化接口，否则报错
*报错信息：NotSerializableException: cn.tedu.seri.Student
*Serializable 这是一个空接口，里面一个方法都没有，作用：当做标志，标志着这个类可以被序列号
*/
public class Student implements Serializable {
    /* x需要给每个进行序列化的文件分配唯一的UID值*/
    //private static final long serialVersionUID = 1l;
    //1.定义并封装属性，提供get（）与set（）方法
    private int sno;//学号
    private String name;//姓名
    private String address;//住址
    private char gender;//性别
    //2.创建无参构造--必须手动提供无参构造，否则会被全参构造覆盖
    public Student() {
        System.out.println("我是Student的无参构造");
    }
    //2.创建全参构造
    public Student(int sno, String name, String address, char gender) {
        this.sno = sno;
        this.name = name;
        this.address = address;
        this.gender = gender;
        System.out.println("我是Student的全参构造");
    }

    public int getSno() {
        return sno;
    }

    public void setSno(int sno) {
        this.sno = sno;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public char getGender() {
        return gender;
    }

    public void setGender(char gender) {
        this.gender = gender;
    }

    @Override
    public String toString() {
        return "Student{" +
                "sno=" + sno +
                ", name='" + name + '\'' +
                ", address='" + address + '\'' +
                ", gender=" + gender +
                '}';
    }
}
